package com.lab;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class G extends JFrame {
	private static final long serialVersionUID = 8665272220673200148L;
	
	private JPanel pnlMain = new JPanel();
	private JTextField text_K = new JTextField();
	private JTextField text_M = new JTextField();
	private JTextField text_K_system = new JTextField();
	private JTextField text_M_system = new JTextField();
	private JButton btnStart = new JButton("Start");
	private JButton btn = new JButton("S");

	public G(String title) {
		setSize(500, 300); 
		setVisible(true); 
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle(title);
		
		text_K.setBounds(25, 25, 200, 25);
		text_M.setBounds(25, 75, 200, 25);
		text_K_system.setBounds(250, 25, 50, 25);
		text_M_system.setBounds(250, 75, 50, 25);
		btnStart.setBounds(25, 125, 75, 25);
		btn.setBounds(250, 125, 50, 25);

		pnlMain.add(text_K);
		pnlMain.add(text_M);
		pnlMain.add(text_K_system);
		pnlMain.add(text_M_system);
		pnlMain.add(btnStart);
		pnlMain.add(btn);

		pnlMain.setBackground(Color.WHITE);
		pnlMain.setLayout(null);
		add(pnlMain);

		btnStart.addActionListener(new ActionListener() { 
			public void actionPerformed(ActionEvent arg0) {
				try{
					String text1K = text_K.getText();
					String text1KS = text_K_system.getText();
					String text2MS = text_M_system.getText();
					
					S s_metod = new S();
					String text2M = s_metod.getValue(text1K, text1KS, text2MS);
					text_M.setText(text2M.toUpperCase());
				}catch (Exception e1) {
					text_M.setText("Exception");
				}
			}
		});
		
		btn.addActionListener(new ActionListener() { 
			public void actionPerformed(ActionEvent arg0) {

					String text1K = text_M.getText();
					String text1KS = text_K_system.getText();
					String text2MS = text_M_system.getText();
					
					text_K.setText(text1K);
					text_K_system.setText(text2MS);
					text_M_system.setText(text1KS);
					text_M.setText("");
			}
		});
	}

	public static void main(String[] args) {
		new G("Lab");
	}
}